﻿using System;
using System.Collections.Generic;
//using System.Linq;
using System.Text;
using System.Windows.Forms;
using DBConnectionLib;

namespace DBSourceToolsLib.Commands
{
    public class DeploymentTargetCommand : Interfaces.IDeploymentTargetCommand
    {
        private DeploymentTargetCommandTypes m_TargetCommandType;
        private Form m_Form;
        public DeploymentTargetCommand(DeploymentTargetCommandTypes oCommandType, Form oForm)
        {
            this.m_TargetCommandType = oCommandType;
            this.m_Form = oForm;
        }
        
        #region IDeploymentTargetCommand Members

        public void Execute(ref DatabaseEx oDatabase, Database oDeploymentTargetDatabase, string strParameters)
        {
            switch (m_TargetCommandType)
            {
                //case DeploymentTargetCommandTypes.NewTarget:
                //    oDatabase.SysObjects.AddDeploymentTarget(oDeploymentTargetDatabase);
                //    break;
                //case DeploymentTargetCommandTypes.DeleteTarget:
                //    oDatabase.SysObjects.DeploymentTargets.DeleteDatabase(oDeploymentTargetDatabase.NickName);
                //    break;
                //case DeploymentTargetCommandTypes.RenameTarget:
                //    {
                //        oDatabase.SysObjects.DeploymentTargets.DeleteDatabase(oDeploymentTargetDatabase.NickName);
                //        Database newDb = new Database(strParameters, oDeploymentTargetDatabase.DataSourceName, oDeploymentTargetDatabase.DatabaseName, null);
                //        oDatabase.SysObjects.AddDeploymentTarget(newDb);
                //        //oDatabase.SysObjects.DeploymentTargets.Save(true);
                //        //sysObjects.WriteDeploymentTargets(oDatabase.Name);
                //    }

                //    break;
                //case DeploymentTargetCommandTypes.SaveTarget:
                //    {
                //        Database oUpdateDB = oDatabase.SysObjects.DeploymentTargets.getDatabase(oDeploymentTargetDatabase.NickName);
                //        oUpdateDB.DataSourceName = oDeploymentTargetDatabase.DataSourceName;
                //        oUpdateDB.DatabaseName = oDeploymentTargetDatabase.DatabaseName;
                //    }
                //    break;
                //case DeploymentTargetCommandTypes.SaveToDisk:
                //    //oDatabase.SysObjects.DeploymentTargets.Save(true);
                //    break;
                //case DeploymentTargetCommandTypes.DeployTarget:
                //    {
                //        oDatabase.SysObjects.DeployTarget(oDeploymentTargetDatabase, this.m_Form);
                //    }
                //    break;
            }
        }

        #endregion
    }
}
